From: Florian Müllner Date: Sun, 20 Dec 2020 22:11:26 +0000 (+0100) Subject: dateMenu: Fix temperature edge case X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~664 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e85d127ae3851099cb6481ec6f0487a3661745a7;p=gnome-shell.git dateMenu: Fix temperature edge case We currently format the temperature with a precision of 0, that is with no digits after the decimal-point. As a result, a temperature like -0.2 shows up as -0. Math.trunc() has the same effect as `%.0f` and handles that edge case correctly, but while at it, we can just as well round the value properly. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3441 Part-of: --- diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 993d49289..33c054c12 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -567,7 +567,7 @@ class WeatherSection extends St.Button { ampm: false, }); const [, tempValue] = fc.get_value_temp(GWeather.TemperatureUnit.DEFAULT); - const tempPrefix = tempValue >= 0 ? ' ' : ''; + const tempPrefix = Math.round(tempValue) >= 0 ? ' ' : ''; let time = new St.Label({ style_class: 'weather-forecast-time', @@ -582,7 +582,7 @@ class WeatherSection extends St.Button { }); let temp = new St.Label({ style_class: 'weather-forecast-temp', - text: '%s%.0f°'.format(tempPrefix, tempValue), + text: '%s%d°'.format(tempPrefix, Math.round(tempValue)), x_align: Clutter.ActorAlign.CENTER, });